<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/10/18 0018
 * Time: 13:24
 */

namespace Admin\Controller;

use Think\Controller;

class CategoryController extends CommonController
{
    function __construct()
    {
        parent::__construct();
        $Category = D('Category');
        $this->categories = $Category->all_category();
    }

    /***
     * 分类管理--首页
     */
    public function index()
    {
        $this->display();
    }

    /***
     * 分类管理--新增
     */
    public function add()
    {
        if (IS_POST) {
            $this->category->create();
            $this->category->add();
            $this->success('恭喜你，新增分类成功', U('index'));
        } else {
            $this->display();
        }
    }

    /***
     * 分类管理--编辑
     */
    public function edit()
    {
        $id = I('get.id');
        $cate = $this->category->find($id);
        $this->assign('cate', $cate);
        $this->display();


    }

    /***
     * 分类管理--删除
     */
    public function delete()
    {
        $id = I('get.id');

    }
}